class Plantern extends GuaAnimation {
    static new(game) {
        let p = new this(game, animationplantern)
        p.setup()
        return p
    }

    setup() {
        // row表示在草地的第几排
        this.row = -1
        this.cooldown = 5
        this.score = 150
        this._sleep = true
    }
    awake(){
        this._sleep = false
    }
    sleep(){
        this._sleep = true
    }

    fire() {
        // 没有僵尸不发射
        if (this._sleep){
            return
        }
        this.cooldown--
        if (this.cooldown == 0) {
            // 开始冷却
            this.cooldown = 20
            // 发射子弹
            let pb = PeaBullet.new(this.game, 'peabullet1')
            let fix = 30
            pb.x = this.x + fix
            pb.y = this.y
            pb.row = this.row
            this.game.scene.addElement(pb)
            let s = this.game.scene
            s.addElement(pb)
            s.bullets.push(pb)
        }
    }

    update() {
        super.update()
        // this.fire()
    }
}